package com.szb.endpoint;

import org.springframework.stereotype.Component;

import javax.websocket.Session;
import java.util.concurrent.ConcurrentHashMap;


public class WebSocketSessionManager {

    private static ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();

    public static Long countSessionNumber(){
        return sessions.mappingCount();
    }

    public static void addSession(String sessionId, Session session) {
        sessions.put(sessionId, session);
    }

    public static Session getSession(String sessionId) {
        return sessions.get(sessionId);
    }

    public static void removeSession(String sessionId) {
        sessions.remove(sessionId);
    }
}